
#ifndef __STRING_UTILS
#define __STRING_UTILS

#include <vector>
#include <stdarg.h>
#include <apr_tables.h>
#include "../iface/debug.h"

/** General string utilities collection class. */
namespace StringUtils
{
   int safe_vscnprintf(char *buffer, const char *format, va_list argpntr);
   char *getDateTimeNowAsString();
   char *getDateTimeNowPlusThisMuchAsString(int secondstime);
   int readFileToBuffer(char **fbuffer, int *fbufferlen, const char *filename, apr_pool_t *mp);
   int readFileToString(char **fstring, const char *filename, apr_pool_t *mp);
   int overwriteFileWithBuffer(const char *fbuffer, int fbufferlen, const char *filename, apr_pool_t *mp);
   int writeBufferToFile(const char *fbuffer, int fbufferlen, const char *filename, apr_pool_t *mp);
   int writeStringToFile(const char *fstring, const char *filename, apr_pool_t *mp);
   char *mpprintf(apr_pool_t *mp, const char *format, ...) PRINTF_LIKE(2, 3);
   char *mpprintf_va(apr_pool_t *mp, const char *format, va_list args);
   char *varprintf(const char *format, ...) PRINTF_LIKE(1, 2);
   char *varprintf_va(const char *format, va_list args);
   void destroyStringList(std::vector<char *> &strlist);
   void destroyStringList(std::vector<char *> *strlist);
   char *flattenStringList(std::vector<char *> *strlist);
   char *flattenStringList(std::vector<char *> *strlist, const char *sep);
   std::vector<char *> *unflattenStringList(const char *strlist, const char *sep);
   int64_t sumNumberList(const char *numlist, const char *sep);
   void aggressiveStringSanitiser(char *tstring);
   char *intersectCSL(const char *csl1, const char *csl2);
   char *differenceCSL(const char *csl1, const char *csl2);
   int qsort_strcmp_wrapper(const void *c1, const void *c2);
   int areCapabilitiesAcceptable(char *capswork, char *capscompute);
   void razeString(char **stringpntr);
   char *replaceWithPoolString(char *oldstring, apr_pool_t *mp);
   int isBinary(const char *bindata, int length);
   void printBinary(const char *bindata, int length);
   const char *mpTrimWhitespaceFromBoth(char *original, apr_pool_t *mp);
};

#endif
